package com.hao.windowloading;

import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;

import com.hao.windowloading.base.BaseActivity;
import com.hao.windowloading.loading.LoadingUtils;

public class MainActivity extends BaseActivity {
    public static final String TAG = MainActivity.class.getSimpleName();

    @Override
    public void findView() {
        setContentView(R.layout.activity_main);
    }

    @Override
    public void initView() {
        loadingUtils.setAgainListener(new LoadingUtils.AgainListener() {
            @Override
            public void onAgainListener() {
                Log.i(TAG, ">>>>onAgainListener>>>>");
                handler.sendMessageDelayed(new Message(), 5000);
            }
        });
    }

    @Override
    public void setClick() {

    }

    public void startLoading(View view) {
        loadingUtils.startLoading();
        handler.sendMessageDelayed(new Message(), 5000);
    }

    public void fileLoading(View view) {
        loadingUtils.startFile();
        handler.sendMessageDelayed(new Message(), 5000);
    }

    public void nullLoading(View view) {
        loadingUtils.startNull();
        handler.sendMessageDelayed(new Message(), 5000);
    }


    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            loadingUtils.recovery();
        }
    };


}
